﻿using System;

public static class ValueUtility
{
    public static void ChangeValue<T>(ref T prop, T value, OnValueChangedEvent<T> evt)
    {
        if ((((T) prop) == null) || !prop.Equals(value))
        {
            T lastValue = prop;
            prop = value;
            if (evt != null)
            {
                evt(value, lastValue);
            }
        }
    }

    public static T Convert<T>(object value)
    {
        try
        {
            return (T) System.Convert.ChangeType(value, typeof(T));
        }
        catch (Exception)
        {
        }
        return default(T);
    }
}

